<template>
	<view>

		<view class="content rows">
			<image :src="image+studentData.img" mode="" style="max-width: 200rpx;height: 200rpx;border-radius: 10rpx;background-color: #F1F1F1;"></image>
			<view class="rowsal pdlft20 w100" style="height: 200rpx;">
				<view class="fs28 col333 bold">{{studentData.name}}</view>
				<view class="rowsb w100">
					<view class="fs26 col666">{{studentData.coach_title}}</view>
					<view class="coach_dsjgdn fs26 col666" @click="gotoeValuate">教练评价</view>
				</view>
				<view class="fs26 col666">{{studentData.tel}}</view>
			</view>
		</view>
		<view>
			<view class="level_user fs30 col333 bold pdBtm20 pdTop20 pdlft20">学员评价</view>
			<view>
				<view class="time_date" v-for="(item,index) in applyEvaluateList" :key="index">
					<view class="rows w100">
						<image src="" mode="" style="max-width: 100rpx;height: 100rpx;border-radius: 10rpx;background-color: #F1F1F1;"></image>
						<view class="w100 pdlft20">
							<view class="rowsb w100 pdTop10">
								<view class="fs28 col333">{{item.name}}</view>
								<view class="fs28 col666">{{item.add_time | formatDate}}</view>
							</view>
							<view class="fs28 col666 pdTop10">{{item.tel}}</view>
							<view class="fs26 col333 pdTop10">{{item.content}}</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="applyEvaluateList=='' ||applyEvaluateList==null " class="text-gray padding text-center">
				暂无评价
			</view>
		</view>
	</view>
</template>

<script>
	import {
		applyEvaluate
	} from '../../../common/path.js'
	const app = getApp().globalData
	export default {
		data() {
			return {
				studentData: {},
				image: '',
				applyEvaluateList: []
			}
		},
		onLoad(option) {
			console.log(JSON.parse(option.detail));
			this.image = app.image
			this.studentData = JSON.parse(option.detail)
			this.applyEvaluate()
		},
		filters: {
			formatDate(data) { //时间戳的过滤
				var date = new Date(data); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
				var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
				var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				return Y + M + D + h + m + s;
			},
		},
		methods: {
			//评价pages/record/gotoeValuate
			gotoeValuate() {
				uni.navigateTo({
					url: '/pages/record/gotoeValuate?id=' + this.studentData.id + '&pid=' + app.userInfo.id
				})
			},

			applyEvaluate() {
				let data = {
					id: this.studentData.id
				}
				this.$axios.axios('POST', applyEvaluate, data)
					.then(res => {
						console.log('获取到的学车记录===>', res);
						if (res.status == 1) {
							this.applyEvaluateList = res.data
						}
					})
					.catch(err => {
						console.log(err);
					})
			}

		}
	}
</script>

<style scoped>
	.content {
		width: 710rpx;
		border-top: 12rpx solid #F1F1F1;
		border-bottom: 12rpx solid #F1F1F1;
		padding: 20rpx;
	}

	.level_user {
		border-bottom: 3rpx solid #F1F1F1;
	}

	.coach_dsjgdn {
		width: 140rpx;
		height: 50rpx;
		line-height: 50rpx;
		text-align: center;
		border: 3rpx solid #F1F1F1;
		border-radius: 10rpx;
		margin-top: -10rpx;
	}

	.time_date {
		width: 710rpx;
		border-bottom: 3rpx solid #F1F1F1;
		padding: 25rpx 20rpx;
	}
</style>
